<?php
namespace app\index\controller;

use think\facade\View;
use think\facade\Db;
use think\facade\Request;
use think\facade\Session;

/**
 * jd详情数据抓取
 */
class Tmpword extends Front
{
    public function index()
    {
        $tmp=new \PhpOffice\PhpWord\TemplateProcessor('x1.docx');//打开模板
        $tmp->setValue('title','文章标题');//替换变量
        $tmp->setValue('body','文章内容');//替换变量
        $tmp->setImageValue('pic', ['path' => 'images/20200417130819785.jpg','width'=>500,'height'=>500]);//添加图片
        $tmp->saveAs('x2.docx');//另存为
        echo '模板生成完成';
        die;
    }
}
